import time
from selenium import webdriver
from selenium.webdriver.common.by import By

from ExcelData import *


class LoginOperation:
    #输入账号密码，点击登录
    def login(self,driver,username,password):
        driver.find_element(By.ID,"username").send_keys(username)
        driver.find_element(By.ID,"password").send_keys(password)
        driver.find_element(By.ID,"login_btn").click()
        time.sleep(1)
    #断言正确登录
    def get_success_result(self,driver):
        result = driver.title
        return result
    #断言用户名不存在
    def get_error_result(self,driver):
        result = driver.find_element(By.XPATH,"/html/body/div/div/div/form/div[1]/span[1]")
        return result
    #断言密码错误
    def get_error_pwd(self,driver):
        result = driver.find_element(By.XPATH,"/html/body/div/div/div/form/div[2]/span[1]")
        return result
    #总结上面的，调用页面源代码
    def get_error_result1(self,driver):
        result = driver.page_source
        return result